﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Zavand.Web.Mvc.Manana.Framework;

namespace Zavand.Web.Mvc.Manana.FrameworkUnitTests
{
    ///<summary>
    ///    This is a test class for BaseApplicationTest and is intended
    ///    to contain all BaseApplicationTest Unit Tests
    ///</summary>
    [TestClass]
    public class BaseApplicationTest
    {
        ///<summary>
        ///    A test for BaseApplication Constructor
        ///</summary>
        [TestMethod]
        public void BaseApplicationConstructorTest()
        {
            var application = new BaseApplication();
            Assert.IsNotNull(application);
        }

        ///<summary>
        ///    A test for ApplicationStart
        ///</summary>
        [TestMethod]
        public void ApplicationStartTest()
        {
            var application = new BaseApplication();
            application.ManualAreaRegistration = true;
            application.ApplicationStart();
        }

        ///<summary>
        ///    A test for RegisterAllAreas
        ///</summary>
        [TestMethod]
        public void RegisterAllAreasTestManual()
        {
            var application = new BaseApplication();
            application.ManualAreaRegistration = true;
            application.RegisterAllAreas();
        }

        ///<summary>
        ///    A test for RegisterAllAreas
        ///</summary>
        [TestMethod]
        public void RegisterAllAreasTestAutomatic()
        {
            var application = new BaseApplication();
            application.ManualAreaRegistration = false;
            try
            {
                application.RegisterAllAreas();
            }
            catch
            {
                return;
            }
            Assert.Fail("This line should never be reached in NON manual mode");
        }

        ///<summary>
        ///    A test for RegisterArea
        ///</summary>
        [TestMethod]
        public void RegisterAreaTest()
        {
            var application = new BaseApplication();
            application.RegisterArea(null, null);
        }

        ///<summary>
        ///    A test for RegisterGlobalFilters
        ///</summary>
        [TestMethod]
        public void RegisterGlobalFiltersTest()
        {
            var application = new BaseApplication();
            var filters = new GlobalFilterCollection();
            application.RegisterGlobalFilters(filters);
            Assert.IsTrue(filters.Count == 1);
        }

        ///<summary>
        ///    A test for RegisterRoutes
        ///</summary>
        [TestMethod]
        public void RegisterRoutesTest()
        {
            var application = new BaseApplication();
            var routes = new RouteCollection();
            application.RegisterRoutes(routes);
            Assert.IsTrue(routes.Count == 1);
        }

        ///<summary>
        ///    A test for IsLocalizationSupported
        ///</summary>
        [TestMethod]
        public void IsLocalizationSupportedTestDefaultValue()
        {
            var application = new BaseApplication();
            Assert.IsTrue(application.IsLocalizationSupported == false);
        }

        ///<summary>
        ///    A test for IsLocalizationSupported
        ///</summary>
        [TestMethod]
        public void IsLocalizationSupportedTest()
        {
            var application = new BaseApplication();
            application.IsLocalizationSupported = true;
            Assert.IsTrue(application.IsLocalizationSupported);
        }
    }
}